package com.mljr.example.base;

import android.os.Bundle;

import com.amap.api.location.AMapLocation;
import com.amap.api.location.AMapLocationClient;
import com.amap.api.location.AMapLocationListener;
import com.ctakit.sdk.app.base.BaseActivity;
import com.ctakit.sdk.app.base.BaseModel;
import com.ctakit.sdk.app.base.BasePresenter;
import com.ctakit.sdk.app.utils.ViewUtil;
import com.mljr.example.R;
import com.mljr.example.ui.h5.Html5Activity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by andyhome on 2016/4/5.
 */

public abstract class MyBaseActivity<T extends BasePresenter, E extends BaseModel> extends BaseActivity<T, E> implements AMapLocationListener {

    //声明AMapLocationClient类对象
    public AMapLocationClient mLocationClient = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }


    ///和MybaseFragment 基本 一样 （修改时记得改MybaseFragment） start
    public void initTitle(String title) {
        ViewUtil.setTextView(this, Config.Server.getTitle(Global.getDevModel(), title), R.id.theme_title);
    }

    public void initBack(String label) {
        BaseUtil.initBack(this,label);
    }


    public void initBack() {
        initBack("");
    }

    public void gotoHtml5Activity(String url) {
        Map<String, Serializable> data = new HashMap<String, Serializable>();
        data.put("url", url);
        gotoActivity(Html5Activity.class, data);
    }

    //启动定位
    protected void initLocation() {
        //初始化定位
        mLocationClient = BaseUtil.initLocation(this);
        //启动定位
        mLocationClient.startLocation();
    }

    public void onLocationChanged(AMapLocation amapLocation) {
        BaseUtil.onLocationChanged(amapLocation,mLocationClient);
    }


}